<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@taglib prefix="s" uri="/struts-tags" %>
<jsp:include page="checkExam.jsp" />
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
 <link rel="stylesheet" type="text/css"  href="css/paper.css" />
 <link rel="stylesheet" type="text/css" href="css/smoothness/jquery-ui.css" />
 <script type="text/javascript" src="js/jquery-2.0.js"></script>
 <script type="text/javascript" src="js/cloud.js" ></script>
 <script type="text/javascript" src="js/jquery-ui.js"></script>
 <script type="text/javascript" src="js/jquery.form.js"></script>
 <script type="text/javascript" src="js/paper_submit.js"></script>
<script type="text/javascript">
$(function(){
	timer(intDiff);
	$(window).resize(function(){
			var left =  $("#main").offset().left+$("#main").width();
			$("#answerCard").css("left",left+20);
	});
	
	//阻止右击
	$(document).bind("contextmenu",function(){
        return false;
	});
	//阻止复制
	$('body').bind("selectstart",function(){
		return false;
	});
	
	
});	
	
function selOption(opt){
	$(opt).addClass("selopt").siblings().removeClass("selopt");
	var aid = $(opt).find("input").attr("name");
	var myAnswer = $(opt).find("input").val();
	$("#"+aid).addClass("selected");
	$(opt).parent().find("input[name=myAnswer]").val(myAnswer);
}

//跳转到指定锚点
function jump(current) {
    $("html, body").animate({
      scrollTop: ($($(current).attr("href")).offset().top-30) + "px"
    }, {
      duration: 500,
      easing: "swing"
    });
    return false;
};


/*
	计时器
*/
var intDiff = parseInt("${paperInfo.lastTestTime}");//倒计时总秒数量

function timer(intDiff){
	window.setInterval(function(){
	var day=0,
		hour=0,
		minute=0,
		second=0;//时间默认值		
	if(intDiff > 0){
		day = Math.floor(intDiff / (60 * 60 * 24));
		hour = Math.floor(intDiff / (60 * 60)) - (day * 24);
		minute = Math.floor(intDiff / 60) - (day * 24 * 60) - (hour * 60);
		second = Math.floor(intDiff) - (day * 24 * 60 * 60) - (hour * 60 * 60) - (minute * 60);
	}else{
		//alert("时间到");
		// var fm = $("#submitPaperForm");
		//  fm.ajaxSubmit(options);
	}
	if (minute <= 9) minute = '0' + minute;
	if (second <= 9) second = '0' + second;
	$('#day_show').html(day+"天");
	$('#hour_show').html('<s id="h"></s>'+hour+'时');
	$('#minute_show').html('<s></s>'+minute+'分');
	$('#second_show').html('<s></s>'+second+'秒');
	$('#lastTime').html(intDiff);  //剩余时间
	intDiff--;
	}, 1000);
} 
</script>
<style>
	#showScore{
	 width:200px;
	 height:300px;
	 padding: 10px 50px;
	 display: none;
	}
	#showScore h2{
		text-align: center;
		font-size:25px;
		color:#333;
		font-family: 新宋体;
	}
	#showScore ul{
		
	}
	#showScore ul li{
		border-bottom:1px solid #ccc;
		height:30px;
		line-height: 30px;
		font-size:16px;
	}
	#showScore ul li b{
		font-size:16px;
	}
	#showScore p {
		margin:10px 0 0 70px ;
		line-height:50px;
	}
	#showScore p img {
	  float:left;
	  border:none;
	  margin-right:10px;
	}
	#showScore p span{
		font-size:15px;
	}
</style>
</head>
<div id="loading"></div>
<body style="background-color:#1c77ac; background-image:url(images/light.png); background-repeat:no-repeat; ">
<span id="lastTime" style="display:none"></span>
	<span style="display:none" id="message">${message }</span>
    <div id="mainBody">
      <div id="cloud1" class="cloud"></div>
      <div id="cloud2" class="cloud"></div>
    </div>  

<div class="paperTop">    
    <span>欢迎使用在线考试系统</span>    
    <ul>
    <li>当前考生 : [ <b id="s_name">${student.stu_name }</b> ]</li>
    <li>学号 : [ <b id="s_id">${student.stu_id }</b> ]</li>
    </ul>    
</div>

<div id="main">
	<div class="paperInfo">
		<h1>${paperInfo.paperName }</h1>
		<ul>
			<li>
				<p>本试卷共有</p>
				<p><b>${paperInfo.questionNum }</b>题</p>
			</li>
			<li>
				<p>卷面总分	</p>			
				<p><b  id="p_total">${paperInfo.totalScore }</b>分</p>
			</li>
			<li>
				<p>答题时间</p>
				<p><b id="p_time">${paperInfo.testTime }</b>分钟</p>
			</li>
			<li style="border:none">
				<p>试卷来源</p>
				<p>exam在线考试系统</p>
			</li>
			

		</ul>
	</div>
 <form action="?" id="submitPaperForm">
    <input type="hidden" name="realAnswer" value="${paperInfo.realAnswer }"/>
	<input type="hidden" name="pid" value="${paperInfo.id }"/>
	<input type="hidden" name="sid" value="${student.stu_id}"/>
	<input type="hidden" name="qscore" value="${paperInfo.totalScore/paperInfo.questionNum }">
	<div class="type">
		<h5>单项选择题</h5>
		一、单项选择题（本大题共${paperInfo.questionNum }小题，
		每小题 ${paperInfo.totalScore/paperInfo.questionNum } 分，
		共${paperInfo.totalScore}分。
		在每小题列出的四个备选项中只有一个是符合题目要求的，请点击选项选择正确的答案 ）
	</div>
	 <s:if test="#request.Question!=null">
        <s:iterator value="#request.Question" status="list" id="question" var="qfm">
		<span id="m<s:property value="id"/>"></span>
		<dl class="question" >
			<dd>
			<input type="hidden" name="qids" value="<s:property value="id"/>"/>
			<input type="hidden" name="myAnswer" value="X"/>
			
			</dd>
			<dt><b>${list.index+1 }、</b>
			<s:property value="content"/>
			<s:property value="option[i]"/>
			</dt>
			<s:iterator value="option" status="opt">
				<dd class="option"  onclick="selOption(this)"><label>
					
				<s:if test="#opt.index==0">
				 <input type="radio" name="a${list.index }" value="A" /> A
				</s:if>
				<s:elseif test="#opt.index==1">
				<input type="radio" name="a${list.index }" value="B" /> B
				</s:elseif>
				<s:elseif test="#opt.index==2">
				<input type="radio" name="a${list.index }" value="C" /> C
				</s:elseif>
				<s:else>
				<input type="radio" name="a${list.index }" value="D" /> D
				</s:else>
				、<s:property /></label>
				</dd>
			</s:iterator>
		</dl>
	</s:iterator>
	</s:if>
	</form>
</div>


	<div id="answerCard">
		<div class="time">
		
		<img src="images/clock.png"/>
		<div class="time-item" style="margin-left:10px">
			<strong id="hour_show">0时</strong>
			<strong id="minute_show">0分</strong>
			<strong id="second_show">0秒</strong>
		</div>
		</div>
		<div class="card">
			<s:if test="#request.Question!=null">
        	<s:iterator value="#request.Question" status="list" >
				<s:if test="#list.index+1<10">
				<a href="#m<s:property value="id"/>" id="a${list.index }" onclick="return jump(this)">0${list.index+1 }</a>
				</s:if>
				<s:else>
				<a href="#m<s:property value="id"/>" id="a${list.index }" onclick="return jump(this)">${list.index+1 }</a>
				</s:else>
			</s:iterator>
			</s:if>
		</div>
		<div class="submitTest">
			<p> <input type="submit" class="btn" value="提交试卷"/></p>
		</div>
		
	</div>
<!-- 成绩框 -->	
	<div id="showScore">
		
	</div>
</body>
</html>
